package com.drojian;

import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

import com.bumptech.glide.Glide;

import java.io.File;

public class GlideBaseActivity extends AppCompatActivity {

    private TextView tv_1;
    private ImageView image_1;
    private TextView tv_2;
    private ImageView image_2;
    private TextView tv_3;
    private ImageView image_3;
    private TextView tv_4;
    private ImageView image_4;
    private TextView tv_5;
    private ImageView image_5;
    private TextView tv_6;
    private ImageView image_6;
    private TextView tv_7;
    private ImageView image_7;
    private TextView tv_8;
    private ImageView image_8;
    private TextView tv_9;
    private ImageView image_9;
    private LinearLayout main;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        EdgeToEdge.enable(this);
        setContentView(R.layout.activity_glide_base);
        initView();
        initData();

    }

    private void initData() {
        tv_1.setTextSize(50);
        Glide.with(this).load("https://www.wanandroid.com/blogimgs/42da12d8-de56-4439-b40c-eab66c227a4b.png").into(image_1);

        tv_2.setTextSize(50);
        tv_2.setText("drawable资源");
        Glide.with(this).load(R.drawable.img).into(image_2);

        tv_3.setTextSize(50);
        tv_3.setText("加载本地图片");
        String path = Environment.getExternalStorageDirectory() + "img.png";
        File file = new File(path);
        Uri uri = Uri.fromFile(file);
        Glide.with(this).load(uri).into(image_3);

        tv_4.setText("加载网络gif");
        tv_4.setTextSize(50);
        String gifUrl = "http://b.hiphotos.baidu.com/zhidao/pic/item/faedab64034f78f066abccc57b310a55b3191c67.jpg";
        Glide.with(this).load(gifUrl).placeholder(R.drawable.img).into(image_4);

        tv_5.setTextSize(50);
        tv_5.setText("加载资源gif");
        //Glide.with(this).load("r.drawable.什么").asGif().placeholder(R.drawable.img).into(image_5);

    }


    private void initView() {
        tv_1 = findViewById(R.id.tv_1);
        image_1 = findViewById(R.id.image_1);
        tv_2 = findViewById(R.id.tv_2);
        image_2 = findViewById(R.id.image_2);
        tv_3 = findViewById(R.id.tv_3);
        image_3 = findViewById(R.id.image_3);
        tv_4 = findViewById(R.id.tv_4);
        image_4 = findViewById(R.id.image_4);
        tv_5 = findViewById(R.id.tv_5);
        image_5 = findViewById(R.id.image_5);
        tv_6 = findViewById(R.id.tv_6);
        image_6 = findViewById(R.id.image_6);
        tv_7 = findViewById(R.id.tv_7);
        image_7 = findViewById(R.id.image_7);
        tv_8 = findViewById(R.id.tv_8);
        image_8 = findViewById(R.id.image_8);
        tv_9 = findViewById(R.id.tv_9);
        image_9 = findViewById(R.id.image_9);
        main = findViewById(R.id.main);
    }
}